package com.xzz.experiment.XuanKe;

import java.util.Scanner;

public class main {
    public static void main(String[] args) {
        Course cour0 = new Course(1, "高数", 4.0f, "cxd", "教101", "10:00");

        Course cour1 = new Course(2, "线代", 3.0f, "fy", "教102", "13:00");

        Course cour2 = new Course(3, "概论", 2.0f, "xx", "教103", "15:30");

        Student st1 = new Student("1", "xzz", "男");

        Student st2 = new Student("2", "wzq", "男");

        Student st3 = new Student("3", "wyh", "男");

        Course courses_t[] = new Course[3];//已开课程

        Course courses_s1 = new Course(0, "", 0.0f, "", "", "");//学生1选课

        Course courses_s2 = new Course(0, "", 0.0f, "", "", "");//学生2选课

        Course courses_s3 = new Course(0, "", 0.0f, "", "", "");//学生3选课

        for (int i = 0; i < 3; i++) {
            courses_t[i] = new Course(0, "", 0.0f, "", "", "");
        }
        System.out.println("欢迎使用选课系统！");
        while (true) {
            System.out.println("请输入您的身份：1.教师 2.学生");
            Scanner s1 = new Scanner(System.in);
            int input = s1.nextInt();
            if (input == 1) {//教师
                System.out.println("已选择教师系统");
                Scanner s2 = new Scanner(System.in);
                while (true) {
                    System.out.println("请输入密码：");
                    int input02 = s2.nextInt();
                    if (input02 == 1) {
                        while (true) {
                            System.out.println();
                            System.out.println();
                            System.out.println("课程表:");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            cour0.show();
                            cour1.show();
                            cour2.show();
                            System.out.println("请输入想要开启的课程(请输入“0”退出)");

                            Scanner s3 = new Scanner(System.in);
                            int input03 = s3.nextInt();
                            if (input03 == 0) {
                                break;
                            }
                            if (input03 == 1) {
                                courses_t[0] = new Course(cour0.getCourseId(), cour0.getCourseName(), cour0.getCredit(), cour0.getTeacher(), cour0.getSite(), cour0.getTime());
                                System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                                System.out.println(courses_t[0].getCourseId() + "   " + courses_t[0].getCourseName() + "      " + courses_t[0].getSite() + "  " + courses_t[0].getTime() + "   " + courses_t[0].getTeacher() + "   " + courses_t[0].getCredit());
                                System.out.println("开课成功");


                            } else if (input03 == 2) {
                                courses_t[1] = new Course(cour1.getCourseId(), cour1.getCourseName(), cour1.getCredit(), cour1.getTeacher(), cour1.getSite(), cour1.getTime());
                                System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                                System.out.println(courses_t[1].getCourseId() + "   " + courses_t[1].getCourseName() + "      " + courses_t[1].getSite() + "  " + courses_t[1].getTime() + "   " + courses_t[1].getTeacher() + "   " + courses_t[1].getCredit());
                                System.out.println("开课成功");
                            } else if (input03 == 3) {
                                courses_t[2] = new Course(cour2.getCourseId(), cour2.getCourseName(), cour2.getCredit(), cour2.getTeacher(), cour2.getSite(), cour2.getTime());
                                System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                                System.out.println(courses_t[2].getCourseId() + "   " + courses_t[2].getCourseName() + "      " + courses_t[2].getSite() + "  " + courses_t[2].getTime() + "   " + courses_t[2].getTeacher() + "   " + courses_t[2].getCredit());
                                System.out.println("开课成功");
                            }

                        }
                        System.out.println("已开课程如下:");
                        System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                        for (int i = 0; i < 3; i++) {
                            System.out.println(courses_t[i].getCourseId() + "   " + courses_t[i].getCourseName() + "      " + courses_t[i].getSite() + "  " + courses_t[i].getTime() + "   " + courses_t[i].getTeacher() + "   " + courses_t[i].getCredit());
                        }
                        break;
                    }
                }

            } else if (input == 2) {//学生
                System.out.println("已选择学生系统\n1.选课  2.退课 3.打印学生课表");
                Scanner scanner = new Scanner(System.in);
                int input06 = scanner.nextInt();
                if (input06 == 1) {
                    while (true) {
                        System.out.println("请输入学生编号（输入0退出）");
                        Scanner s5 = new Scanner(System.in);
                        int input05 = s5.nextInt();
                        if (input05 == 0) {
                            break;
                        }
                        if (input05 == 1) {
                            System.out.println("以下课程可选");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            for (int i = 0; i < 3; i++) {
                                if (courses_t[i].getCourseId() != 0) {
                                    System.out.println(courses_t[i].getCourseId() + "   " + courses_t[i].getCourseName() + "      " + courses_t[i].getSite() + "  " + courses_t[i].getTime() + "   " + courses_t[i].getTeacher() + "   " + courses_t[i].getCredit());
                                }
                            }
                            System.out.println("请选课（仅能选一门）输入”0“退出");
                            Scanner scanner1 = new Scanner(System.in);
                            int input07 = scanner1.nextInt();
                            if (input07 == 0) {
                                break;
                            }
                            if (input07 == 1) {
                                courses_s1.setCourseId(cour0.getCourseId());
                                courses_s1.setCourseName(cour0.getCourseName());
                                courses_s1.setSite(cour0.getSite());
                                courses_s1.setCredit(cour0.getCredit());
                                courses_s1.setTeacher(cour0.getTeacher());
                                courses_s1.setTime(cour0.getTime());
                            }
                            if (input07 == 2) {
                                courses_s1.setCourseId(cour1.getCourseId());
                                courses_s1.setCourseName(cour1.getCourseName());
                                courses_s1.setSite(cour1.getSite());
                                courses_s1.setCredit(cour1.getCredit());
                                courses_s1.setTeacher(cour1.getTeacher());
                                courses_s1.setTime(cour1.getTime());
                            }
                            if (input07 == 3) {
                                courses_s1.setCourseId(cour2.getCourseId());
                                courses_s1.setCourseName(cour2.getCourseName());
                                courses_s1.setSite(cour2.getSite());
                                courses_s1.setCredit(cour2.getCredit());
                                courses_s1.setTeacher(cour2.getTeacher());
                                courses_s1.setTime(cour2.getTime());
                            }

                        } else if (input05 == 2) {
                            System.out.println("以下课程可选");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            for (int i = 0; i < 3; i++) {
                                if (courses_t[i].getCourseId() != 0) {
                                    System.out.println(courses_t[i].getCourseId() + "   " + courses_t[i].getCourseName() + "      " + courses_t[i].getSite() + "  " + courses_t[i].getTime() + "   " + courses_t[i].getTeacher() + "   " + courses_t[i].getCredit());
                                }
                            }
                            System.out.println("请选课（仅能选一门）输入”0“退出");
                            Scanner scanner1 = new Scanner(System.in);
                            int input07 = scanner1.nextInt();
                            if (input07 == 0) {
                                break;
                            }
                            if (input07 == 1) {
                                courses_s2.setCourseId(cour0.getCourseId());
                                courses_s2.setCourseName(cour0.getCourseName());
                                courses_s2.setSite(cour0.getSite());
                                courses_s2.setCredit(cour0.getCredit());
                                courses_s2.setTeacher(cour0.getTeacher());
                                courses_s2.setTime(cour0.getTime());
                            }
                            if (input07 == 2) {
                                courses_s2.setCourseId(cour1.getCourseId());
                                courses_s2.setCourseName(cour1.getCourseName());
                                courses_s2.setSite(cour1.getSite());
                                courses_s2.setCredit(cour1.getCredit());
                                courses_s2.setTeacher(cour1.getTeacher());
                                courses_s2.setTime(cour1.getTime());
                            }
                            if (input07 == 3) {
                                courses_s2.setCourseId(cour2.getCourseId());
                                courses_s2.setCourseName(cour2.getCourseName());
                                courses_s2.setSite(cour2.getSite());
                                courses_s2.setCredit(cour2.getCredit());
                                courses_s2.setTeacher(cour2.getTeacher());
                                courses_s2.setTime(cour2.getTime());
                            }

                        } else if (input05 == 3) {
                            System.out.println("以下课程可选");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            for (int i = 0; i < 3; i++) {
                                if (courses_t[i].getCourseId() != 0) {
                                    System.out.println(courses_t[i].getCourseId() + "   " + courses_t[i].getCourseName() + "      " + courses_t[i].getSite() + "  " + courses_t[i].getTime() + "   " + courses_t[i].getTeacher() + "   " + courses_t[i].getCredit());
                                }
                            }
                            System.out.println("请选课（仅能选一门）输入”0“退出");
                            Scanner scanner1 = new Scanner(System.in);
                            int input07 = scanner1.nextInt();
                            if (input07 == 0) {
                                break;
                            }
                            if (input07 == 1) {
                                courses_s3.setCourseId(cour0.getCourseId());
                                courses_s3.setCourseName(cour0.getCourseName());
                                courses_s3.setSite(cour0.getSite());
                                courses_s3.setCredit(cour0.getCredit());
                                courses_s3.setTeacher(cour0.getTeacher());
                                courses_s3.setTime(cour0.getTime());
                            }
                            if (input07 == 2) {
                                courses_s3.setCourseId(cour1.getCourseId());
                                courses_s3.setCourseName(cour1.getCourseName());
                                courses_s3.setSite(cour1.getSite());
                                courses_s3.setCredit(cour1.getCredit());
                                courses_s3.setTeacher(cour1.getTeacher());
                                courses_s3.setTime(cour1.getTime());
                            }
                            if (input07 == 3) {
                                courses_s3.setCourseId(cour2.getCourseId());
                                courses_s3.setCourseName(cour2.getCourseName());
                                courses_s3.setSite(cour2.getSite());
                                courses_s3.setCredit(cour2.getCredit());
                                courses_s3.setTeacher(cour2.getTeacher());
                                courses_s3.setTime(cour2.getTime());
                            }
                        }
                    }
                }
                if (input06 == 2) {
                    while (true) {

                        System.out.println("请输入学生编号（输入0退出）");
                        Scanner s5 = new Scanner(System.in);
                        int input05 = s5.nextInt();
                        if (input05 == 0) {
                            break;
                        }
                        if (input05 == 1) {
                            System.out.println("课表如下：");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            System.out.println(courses_s1.getCourseId() + "   " + courses_s1.getCourseName() + "      " + courses_s1.getSite() + "  " + courses_s1.getTime() + "   " + courses_s1.getTeacher() + "   " + courses_s1.getCredit());
                            System.out.println("是否要退课？1.是 2.不是");
                            Scanner scanner2 = new Scanner(System.in);
                            int input08 = scanner2.nextInt();
                            if (input08 == 1) {
                                courses_s1.setCourseId(0);
                                courses_s1.setCourseName("");
                                courses_s1.setSite("");
                                courses_s1.setCredit(0.0f);
                                courses_s1.setTeacher("");
                                courses_s1.setTime("");
                            }
                        }
                        if (input05 == 2) {
                            System.out.println("课表如下：");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            System.out.println(courses_s2.getCourseId() + "   " + courses_s2.getCourseName() + "      " + courses_s2.getSite() + "  " + courses_s1.getTime() + "   " + courses_s1.getTeacher() + "   " + courses_s1.getCredit());
                            System.out.println("是否要退课？1.是 2.不是");
                            Scanner scanner2 = new Scanner(System.in);
                            int input08 = scanner2.nextInt();
                            if (input08 == 1) {
                                courses_s2.setCourseId(0);
                                courses_s2.setCourseName("");
                                courses_s2.setSite("");
                                courses_s2.setCredit(0.0f);
                                courses_s2.setTeacher("");
                                courses_s2.setTime("");
                            }
                        }
                        if (input05 == 3) {
                            System.out.println("课表如下：");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            System.out.println(courses_s3.getCourseId() + "   " + courses_s3.getCourseName() + "      " + courses_s3.getSite() + "  " + courses_s3.getTime() + "   " + courses_s3.getTeacher() + "   " + courses_s3.getCredit());
                            System.out.println("是否要退课？1.是 2.不是");
                            Scanner scanner2 = new Scanner(System.in);
                            int input08 = scanner2.nextInt();
                            if (input08 == 1) {
                                courses_s3.setCourseId(0);
                                courses_s3.setCourseName("");
                                courses_s3.setSite("");
                                courses_s3.setCredit(0.0f);
                                courses_s3.setTeacher("");
                                courses_s3.setTime("");
                            }
                        }

                    }
                }
                if (input06 == 3) {//打印学生选课
                    while (true) {
                        System.out.println();
                        System.out.println("请输入需要打印的学生的课表(输入0退出)");
                        Scanner scanner2 = new Scanner(System.in);
                        int input08 = scanner2.nextInt();
                        if (input08 == 0) {
                            break;
                        }
                        if (input08 == 1) {
                            System.out.print("学号 |姓名 |性别|");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            System.out.print(st1.getStudentId() + "   " + st1.getStudentName() + " " + st1.getSex());
                            System.out.print("  " + courses_s1.getCourseId() + "   " + courses_s1.getCourseName() + "      " + courses_s1.getSite() + "  " + courses_s1.getTime() + "   " + courses_s1.getTeacher() + "   " + courses_s1.getCredit());

                        }
                        if (input08 == 2) {
                            System.out.print("学号 |姓名 |性别|");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            System.out.print(st2.getStudentId() + "   " + st2.getStudentName() + " " + st2.getSex());
                            System.out.print("  " + courses_s2.getCourseId() + "   " + courses_s2.getCourseName() + "      " + courses_s2.getSite() + "  " + courses_s2.getTime() + "   " + courses_s2.getTeacher() + "   " + courses_s2.getCredit());
                        }
                        if (input08 == 3) {
                            System.out.print("学号 |姓名 |性别| ");
                            System.out.println("课程号 |课程  |地点 |时间  |授课老师|绩点");
                            System.out.print(st3.getStudentId() + "   " + st3.getStudentName() + "  " + st3.getSex());
                            System.out.print("  " + courses_s3.getCourseId() + "   " + courses_s3.getCourseName() + "      " + courses_s3.getSite() + "  " + courses_s3.getTime() + "   " + courses_s3.getTeacher() + "   " + courses_s3.getCredit());
                        }
                    }
                }
            }
            if (input == 0)
                break;
        }
    }
}